import request from '@/utils/request';
import { API_PATH_PRE, BASE_HEADERS } from '@/generic/ConfigParams';

// trash
const TRASH = "trash";
export async function queryTrash(params = {}, parse = false) {

    const api_url = `${API_PATH_PRE}${TRASH}${params.fileid ? `/${params.fileid}` : ''}`;
    console.log("==>> queryTrash", api_url)
    return await request(api_url, {
        headers: BASE_HEADERS,
        parseResponse: parse,
    });
}
export async function deleteTrash(params = {}, parse = false) {

    const api_url = `${API_PATH_PRE}${TRASH}${params.id ? `/${params.id}` : ''}`;
    console.log("==>> deleteTrash", api_url)
    return await request(api_url, {
        method: 'DELETE',
        headers: BASE_HEADERS,
        parseResponse: parse,
    });
}
export async function restoreTrash(params = {}, parse = false) {

    const api_url = `${API_PATH_PRE}${TRASH}${params.id ? `/${params.id}` : ''}`;
    console.log("==>> restoreTrash", api_url)
    return await request(api_url, {
        method: 'POST',
        headers: BASE_HEADERS,
        parseResponse: parse,
    });
}

// share
const SHARE = "share";
export async function queryShare(params = {}, parse = false) {

    const api_url = `${API_PATH_PRE}${SHARE}${params.fileid ? `/${params.fileid}` : ''}`;
    console.log("==>> queryTrash", api_url)
    return await request(api_url, {
        headers: BASE_HEADERS,
        parseResponse: parse,
    });
}
export async function deleteShare(params = {}, parse = false) {

    if (params.id) {
        const api_url = `${API_PATH_PRE}${SHARE}/${params.id}`;
        console.log("==>> deleteShare", api_url)
        return await request(api_url, {
            method: 'DELETE',
            headers: BASE_HEADERS,
            parseResponse: parse,
        });
    }

    return false;
}